//
//  SettingViewController.m
//  Double
//
//  Created by dllo on 15/5/25.
//  Copyright (c) 2015年 袁庆秋. All rights reserved.
//

#import "SettingViewController.h"
#import "LoginViewController.h"
#import "AboutUsViewController.h"

@interface SettingViewController ()<UITableViewDataSource, UITableViewDelegate>

@end

@implementation SettingViewController

- (void)dealloc
{
    [super dealloc];
}


- (void)awakeFromNib
{
    [super awakeFromNib];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.title = @"设置";
    [self createView];
    // Do any additional setup after loading the view.
}


#pragma mark 创建TableView
- (void)createView
{
    self.tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height) style:UITableViewStylePlain];
    self.tableView.dataSource = self;
    self.tableView.delegate = self;
    [self.view addSubview:self.tableView];
    [self.tableView release];
}
#pragma mark 设置每行cell高度
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 50;
}
#pragma mark 返回cell行数
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
       return 7;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    static NSString * cellInde = @"cell";
    UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:cellInde];
    if (!cell) {
        cell = [[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:cellInde]autorelease];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    if (indexPath.row == 0) {
        [cell.textLabel setText:@"2G/3G/4G模式下载"];
        UISwitch *switchview = [[UISwitch alloc] initWithFrame:CGRectZero];
        [switchview addTarget:self action:@selector(StyleSwitchAction:) forControlEvents:UIControlEventValueChanged];
        cell.accessoryView = switchview;
        [switchview release];
    } else if (indexPath.row == 1) {
        [cell.textLabel setText:@"消息提示"];
        UISwitch *switchview = [[UISwitch alloc] initWithFrame:CGRectZero];
        [switchview addTarget:self action:@selector(MessageSwitchAction:) forControlEvents:UIControlEventValueChanged];
        cell.accessoryView = switchview;
        [switchview release];
    } else if (indexPath.row == 2) {
        [cell.textLabel setText:@"清除缓存"];
     //   [cell.detailTextLabel setText:@"40.1M"];
    } else if (indexPath.row == 3) {
        [cell.textLabel setText:@"评分加油"];
    } else if (indexPath.row == 4) {
        
        [cell.textLabel setText:@"关于我们"];
    }
    return cell;
}
#pragma mark 网络模式设置
- (void)StyleSwitchAction:(id)sender
{
    
}
#pragma mark 消息提示设置
- (void)MessageSwitchAction:(id)sender
{
    
}
#pragma mark 点击每行cell 触发事件
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
     if (indexPath.row == 2)
    {
        UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"提示" message:@"主人,你确定要删除所有选项" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
        [alert show];
        [alert release];
    } else if (indexPath.row == 3)
    {
        UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"提示" message:@"评分成功" delegate:self cancelButtonTitle:@"取消" otherButtonTitles:@"确定", nil];
        [alert show];
        [alert release];
    } else if (indexPath.row == 4)
    {
        AboutUsViewController * about = [[AboutUsViewController alloc]init];
        [self.navigationController pushViewController:about animated:YES];
    }
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
